<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	request.setAttribute("basePath",basePath);
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>管理员列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${basePath}css/layui.css" media="all">
</head>
<body>
<fieldset class="layui-elem-field layui-field-title">
    <c:choose>
        <c:when test="${flag}">
            <legend>修改管理员</legend>
        </c:when>
        <c:otherwise>
            <legend>添加管理员</legend>
        </c:otherwise>
    </c:choose>

</fieldset>
<form class="layui-form" method="post" action="/AdminServlet">


    <c:choose>
        <c:when test="${flag}">
            <input type="hidden" name="action" value="update">
            <input type="hidden" name="username" value="${admin.username}">
        </c:when>
        <c:otherwise>
            <input type="hidden" name="action" value="insert">
        </c:otherwise>
    </c:choose>

    <input type="hidden" name="pk_role" value="01">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input maxlength="20" required
                       <c:if test="${flag}">disabled</c:if> type="text" name="username" autocomplete="off" class="layui-input" value="${admin.username}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input maxlength="20" required type="text" name="password" autocomplete="off" class="layui-input" value="${admin.password}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">姓名</label>
            <div class="layui-input-inline">
                <input maxlength="20" required type="text" name="nickname" autocomplete="off" class="layui-input" value="${admin.nickname}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="submit">提交</button>
            <a type="reset" class="layui-btn layui-btn-primary" href="/AdminServlet?action=query">取消</a>
        </div>
    </div>
</form>
<script src="${basePath}js/layui.all.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    layui.use('form', function () {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });
</script>
</body>
</html>
